/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "securec.h"

#include "asy_key_generator.h"
#include "asy_key_generator_spi.h"
#include "blob.h"
#include "memory.h"
#include "params_parser.h"
#include "rsa_asy_key_generator_openssl.h"
#include "pri_key.h"
#include "securec.h"

using namespace std;
using namespace testing::ext;

namespace {
class CryptoRsaAsyKeyPemTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp();
    void TearDown();
};

void CryptoRsaAsyKeyPemTest::SetUpTestCase() {}
void CryptoRsaAsyKeyPemTest::TearDownTestCase() {}
void CryptoRsaAsyKeyPemTest::SetUp() {}
void CryptoRsaAsyKeyPemTest::TearDown() {}

constexpr int32_t OPENSSL_RSA_KEY_SIZE_1024 = 1024;
constexpr int32_t OPENSSL_RSA_KEY_SIZE_2048 = 2048;

static string g_testPrikeyPkcs1Str512 = "-----BEGIN RSA PRIVATE KEY-----\n"
"MIIBOQIBAAJBAKG0KN3tjZM8dCNfCg9bcmZM3Bhv/mRrMxuvua2Ru8Kr1NL+/wye\n"
"EMnIARFr+Alf1Tyfjy0PWwFnf8jHWRsz0vkCAwEAAQJAWaTy8vV7AyEEkYdioFjl\n"
"9uitK68KrMjxMGwe16ZvHOAcF1+DvEZpALCs6Stn4vh3zas7FNCxCbd5ptCjHHnM\n"
"wQIhANCYrfBv6m/kADdb9BYpdhMtp1uH3ucf9yMp9b2cr3V1AiEAxnNzDcvW2aOt\n"
"B4+WCEX+tTD3hSBbcv1sKrCApdu3gvUCIEn4WnYQucnDyG/ZI81YFo7meZpzrA+5\n"
"viGyF3qNvYqhAiAq/6jWPGx5C7XaBYqEkGX37Hw1JCWsbKybM1MsnMbOYQIgG1P4\n"
"2PckY+Ho8KCyXy8ABT6vVE8T7glwpNDQQBE87D0=\n"
"-----END RSA PRIVATE KEY-----\n";

static string g_testPrikeyPkcs8Str512 = "-----BEGIN PRIVATE KEY-----\n"
"MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAobQo3e2Nkzx0I18K\n"
"D1tyZkzcGG/+ZGszG6+5rZG7wqvU0v7/DJ4QycgBEWv4CV/VPJ+PLQ9bAWd/yMdZ\n"
"GzPS+QIDAQABAkBZpPLy9XsDIQSRh2KgWOX26K0rrwqsyPEwbB7Xpm8c4BwXX4O8\n"
"RmkAsKzpK2fi+HfNqzsU0LEJt3mm0KMceczBAiEA0Jit8G/qb+QAN1v0Fil2Ey2n\n"
"W4fe5x/3Iyn1vZyvdXUCIQDGc3MNy9bZo60Hj5YIRf61MPeFIFty/WwqsICl27eC\n"
"9QIgSfhadhC5ycPIb9kjzVgWjuZ5mnOsD7m+IbIXeo29iqECICr/qNY8bHkLtdoF\n"
"ioSQZffsfDUkJaxsrJszUyycxs5hAiAbU/jY9yRj4ejwoLJfLwAFPq9UTxPuCXCk\n"
"0NBAETzsPQ==\n"
"-----END PRIVATE KEY-----\n";

static string g_testPubkeyPkcs1Str512 = "-----BEGIN RSA PUBLIC KEY-----\n"
"MEgCQQChtCjd7Y2TPHQjXwoPW3JmTNwYb/5kazMbr7mtkbvCq9TS/v8MnhDJyAER\n"
"a/gJX9U8n48tD1sBZ3/Ix1kbM9L5AgMBAAE=\n"
"-----END RSA PUBLIC KEY-----\n";

static string g_testPubkeyX509Str512 = "-----BEGIN PUBLIC KEY-----\n"
"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKG0KN3tjZM8dCNfCg9bcmZM3Bhv/mRr\n"
"Mxuvua2Ru8Kr1NL+/wyeEMnIARFr+Alf1Tyfjy0PWwFnf8jHWRsz0vkCAwEAAQ==\n"
"-----END PUBLIC KEY-----\n";

static string g_testPrikeyPkcs1Str768 = "-----BEGIN RSA PRIVATE KEY-----\n"
"MIIBywIBAAJhAPxoq7Nw6sd9nQHV4vh25TBFFOGJvcyST+ev1vvtQE1BKZ22pg5V\n"
"Ktx0Up2zombb7ZmdB0CfyqSH3fQ9im6GHfchE9xPUe47UcF4LDnuvRnzwwFi8AxB\n"
"iLSC4BcvsOYR0wIDAQABAmABimIB5l6IeSvMJxILki4z7TgDaGPQK9RxBZG6V+hc\n"
"kFlArSy2Sa7JSax3afFDz3PQsdVnasx0JGalmsXdsgDWDKZr+WBC5/8h+DZ74+9a\n"
"AYrYfApdUnJd4lEBwXJTtQECMQD+55b0UvdY7tua7jukEhrtE7nHBgfMHZCh5Mye\n"
"xIAtT5NNPqDacFiqwOsZjxiRYfsCMQD9flXlxTpfh905rl3Z5Zd8TQziNzgIWeO0\n"
"eXuzN4XsEbilfqVc0WMGwqq0YIrK4AkCMQCL/nL4Ymx4Ck7PqxFUTaE+HTxFovk7\n"
"T+10DG2YsMDYocB7hu7eqR75QJSd5+oNRmsCMQCKhNKjcBbpxPBaaLHYM+GHhwMX\n"
"Sl1QEu6e3BOAZ0LDMRvZM09hXPnj49QsJOUy3yECMHYS7JtNGAbkAkNaQzRmq4Rm\n"
"/O7AemtWRCdj0h4bHuR4HBYDYbA/qoonqXDxLG16zA==\n"
"-----END RSA PRIVATE KEY-----\n";

static string g_testPrikeyPkcs8Str768 = "-----BEGIN PRIVATE KEY-----\n"
"MIIB5QIBADANBgkqhkiG9w0BAQEFAASCAc8wggHLAgEAAmEA/Girs3Dqx32dAdXi\n"
"+HblMEUU4Ym9zJJP56/W++1ATUEpnbamDlUq3HRSnbOiZtvtmZ0HQJ/KpIfd9D2K\n"
"boYd9yET3E9R7jtRwXgsOe69GfPDAWLwDEGItILgFy+w5hHTAgMBAAECYAGKYgHm\n"
"Xoh5K8wnEguSLjPtOANoY9Ar1HEFkbpX6FyQWUCtLLZJrslJrHdp8UPPc9Cx1Wdq\n"
"zHQkZqWaxd2yANYMpmv5YELn/yH4Nnvj71oBith8Cl1Scl3iUQHBclO1AQIxAP7n\n"
"lvRS91ju25ruO6QSGu0TuccGB8wdkKHkzJ7EgC1Pk00+oNpwWKrA6xmPGJFh+wIx\n"
"AP1+VeXFOl+H3TmuXdnll3xNDOI3OAhZ47R5e7M3hewRuKV+pVzRYwbCqrRgisrg\n"
"CQIxAIv+cvhibHgKTs+rEVRNoT4dPEWi+TtP7XQMbZiwwNihwHuG7t6pHvlAlJ3n\n"
"6g1GawIxAIqE0qNwFunE8Fposdgz4YeHAxdKXVAS7p7cE4BnQsMxG9kzT2Fc+ePj\n"
"1Cwk5TLfIQIwdhLsm00YBuQCQ1pDNGarhGb87sB6a1ZEJ2PSHhse5HgcFgNhsD+q\n"
"iiepcPEsbXrM\n"
"-----END PRIVATE KEY-----\n";

static string g_testPubkeyPkcs1Str768 = "-----BEGIN RSA PUBLIC KEY-----\n"
"MGgCYQD8aKuzcOrHfZ0B1eL4duUwRRThib3Mkk/nr9b77UBNQSmdtqYOVSrcdFKd\n"
"s6Jm2+2ZnQdAn8qkh930PYpuhh33IRPcT1HuO1HBeCw57r0Z88MBYvAMQYi0guAX\n"
"L7DmEdMCAwEAAQ==\n"
"-----END RSA PUBLIC KEY-----\n";

static string g_testPubkeyX509Str768 = "-----BEGIN PUBLIC KEY-----\n"
"MHwwDQYJKoZIhvcNAQEBBQADawAwaAJhAPxoq7Nw6sd9nQHV4vh25TBFFOGJvcyS\n"
"T+ev1vvtQE1BKZ22pg5VKtx0Up2zombb7ZmdB0CfyqSH3fQ9im6GHfchE9xPUe47\n"
"UcF4LDnuvRnzwwFi8AxBiLSC4BcvsOYR0wIDAQAB\n"
"-----END PUBLIC KEY-----\n";

static string g_testPrikeyPkcs1Str1024 = "-----BEGIN RSA PRIVATE KEY-----\n"
"MIICXQIBAAKBgQCwIN3mr21+N96ToxnVnaS+xyK9cNRAHiH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4qTaBg5LxgSHy2gC+bvEpuIuRe64yXGuM/\n"
"aP+ZvmIj9QBIVI9mJD8jLEOvQBBpAgMBAAECgYAS8EXME1r7sng9edFCVgQr+2+x\n"
"3RsFlffdx5pwy5seXpZVlumGW0ur58xME88uNea2kL5onsu+bKX7BOL9OzET2/Fb\n"
"kmdu5FPjyudn9fCrR6jMN4R4gFGumyvtG+vty2uDOvibjIwer1oOCnGPwhHugeR/\n"
"CeZavTAzcW6JWWPrnQJBAOKd541nWFROSPgPc76IKLebERUR4mumquZIWiVExv6K\n"
"jOshEq4mWBw6z4aqLZ8d85NMvsuSlh7xJWB7cnFR1UsCQQDG9xleT5vIwWh62ueV\n"
"wxHXdUdSmhV6hX2qS/oIBYuVsx2B/u4qaClrVindA8M1BCqQ++uq19HX0lZni7LW\n"
"pESbAkAtNTcGPIGgf+WKpvp+HgeRaTvlKiYzN5KMUg65tJjGGrm2BmkFmNym9QyF\n"
"XtmvDniTABJn5hxQm+bK8pWICb01AkEAoXsPJdIqt6bxazSbXJszsdDHkCzqXcRW\n"
"F48OYNBPV7JFsqn7FoPvieQmmfBh0HePLJipzsDW2Pknk2Z4QWiVHQJBAKfvpenw\n"
"cKMaAsfD2+DtjIgvbzL9fJ8XJpkDPMr5iJpqQ3BDo14a1dKy4YJzLJ+lpwen3HLy\n"
"pdA0pKTDTf/m8M4=\n"
"-----END PRIVATE KEY-----\n";

static string g_testPubkeyPkcs1Str1024 = "-----BEGIN RSA PUBLIC KEY-----\n"
"MIGJAoGBALAg3eavbX433pOjGdWdpL7HIr1w1EAeIcaCtuMfDpECPdX6X5ZjrwiE\n"
"h7cO51WXMT2gyN45DCQySr/8cLE2UiUVHo7qlrSatdLA9ETtgob3sJ4qTaBg5Lxg\n"
"SHy2gC+bvEpuIuRe64yXGuM/aP+ZvmIj9QBIVI9mJD8jLEOvQBBpAgMBAAE=\n"
"-----END RSA PUBLIC KEY-----\n";

static string g_testPubkeyX509Str1024 = "-----BEGIN PUBLIC KEY-----\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//RKRqpUfQIDAQAB\n"
"-----END RSA PUBLIC KEY-----\n";

static string g_testPubkeyX509Str2048 = "-----BEGIN PUBLIC KEY-----\n"
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr4U12jTPgkgtjUa1Co6i\n"
"EUOTsgwr9gM2N6SJ479C+EZ4xhcSz3SAXwkds3p0j88s/M0qjnINYa2p+RtDnPbL\n"
"ezrLXsCa5wTvHVqOIm8mH99GcfHQdKPWx2FICbLSgrQu6CyFFjs62aA5yKYeXXC1\n"
"CSmu29YjcLMvh00OH3h3bYXcPwMqGiGJ7MWs1iRLbjV5m8FgL8OJntggAB5eYGfk\n"
"P7dLuuOw8hIT8Xsxuwer/V67O9s5kweDOxa4UKmj+MrZc9iHzDnt6unRRSr//boH\n"
"FJAikSUTIaIUDrWG9UkboAA8QFZ5OAjbw5LpLKnBfxxVxIFeMRI4MVrF//RKRqpU\n"
"fQIDAQAB\n"
"-----END PUBLIC KEY-----\n";

static string g_testPrikeyPkcs1Str3072 = "-----BEGIN RSA PRIVATE KEY-----\n"
"MIIG4wIBAAKCAYEAyBxneAYLMyWepegDigzAXZUmB3F7WtBJ9YmfAwafMQDqtDMQ\n"
"fHN/qodxSJ6ZRlvpDkALbiZmw0LpN+DIMJCB3o28L21B0lpcGJDfYFKjdWP2l4si\n"
"bVv69zV/5k2T5asLLSdrm12umkCwm1C1UoT5Ivqde4ipLQFhMYPPzB3/hz3eRTcx\n"
"ZUWm0uOWsXlvImTP4aXeEFTatBWzglWgtOucUG3cezLIzdyD88ZBi27lzo74ocjI\n"
"GhDC4pdS9DvQ+kp9KvYG+DslxOpbTN4SGQaiQkl+k1cJ6keY8cisG30exDFkLyVm\n"
"fFjPMfKulc0h03xIY3nPkfC7dc8hB8nzvzZbCzr1cDjJR80ekSEmUfj2eUCMSxaS\n"
"PvAoafsxSLTZsjFb+6hTJPJ8GdxtFg1FrzA51QSxhRivobdvqntmQU3K8Ne2KVmq\n"
"64UH2a69G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Ew0jDhq1H2qBGWWs\n"
"hfQJrI292GDIvkZmMUIL8iv5V+tAUpz/salrvppS4Hvqj4MMV6WBDuUJlB1WBONE\n"
"zoKO0cFf79ZfcAF2VOkCgcAeF07lkaKzr+0/dbXzRdY/dSdicVMM0AFd3VIDLJt7\n"
"zHWeK9HVy9czk8H83FTzCu/q7e/7PPCFBLyBQi60dg+jTWysXdIcQ35aD5hPU4T/\n"
"5Ua2PKc5orWVutKpdXxb7fvFJKM62ViOXDcWIxX1RAEWY9Q7jem1sHgm5HvKfGij\n"
"nIYUxGUVqorWrp3uiurjYBva6bdTK044BSN/QWGW5VyJxFO1oX0GGj8sc4pzQ9OY\n"
"hhYTWfVuTdsBTAXG2zeqbno=\n"
"-----END PRIVATE KEY-----\n";

static string g_testPubkeyPkcs1Str3072 = "-----BEGIN RSA PUBLIC KEY-----\n"
"MIIBigKCAYEAyBxneAYLMyWepegDigzAXZUmB3F7WtBJ9YmfAwafMQDqtDMQfHN/\n"
"qodxSJ6ZRlvpDkALbiZmw0LpN+DIMJCB3o28L21B0lpcGJDfYFKjdWP2l4sibVv6\n"
"9zV/5k2T5asLLSdrm12umkCwm1C1UoT5Ivqde4ipLQFhMYPPzB3/hz3eRTcxZUWm\n"
"0uOWsXlvImTP4aXeEFTatBWzglWgtOucUG3cezLIzdyD88ZBi27lzo74ocjIGhDC\n"
"4pdS9DvQ+kp9KvYG+DslxOpbTN4SGQaiQkl+k1cJ6keY8cisG30exDFkLyVmfFjP\n"
"MfKulc0h03xIY3nPkfC7dc8hB8nzvzZbCzr1cDjJR80ekSEmUfj2eUCMSxaSPvAo\n"
"afsxSLTZsjFb+6hTJPJ8GdxtFg1FrzA51QSxhRivobdvqntmQU3K8Ne2KVmq64UH\n"
"2a69GcH2oWejG4mIeT4t1gBFZ+peqOsIgq/VeYI2WmNb1co3pvRBuIAcG1sgTaU8\n"
"AilKi6YBEcNxAgMBAAE=\n"
"-----END RSA PUBLIC KEY-----\n";

static string g_testPubkeyX509Str3072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mpASrVHuz9nXV4JWrhcvpUifPKqwrhPHrhCeGOpj15+buP\n"
"DFs3kWif9rJG2ygqNdHpa2gQIX3c\n"
"-----END PRIVATE KEY-----\n";

static string g_testPubkeyPkcs1Str4096 = "-----BEGIN RSA PUBLIC KEY-----\n"
"MIICCgKCAgEAnDx8bd6se93OKCpW6F5vi9eqAvmocX6X6wo7RfE4Bdt/sBMkKEiz\n"
"MM9BBZacBDFX5CnEzZeuj8ILYJlx29jkuQ2nseG56na/YLCfeeHAM4tHEc3WRhM8\n"
"GOeMra1mcI4wqS8hbAvFJwrn2Ej5FD/UzCyl4vME3Nf8jgQ3thmsDOLiAgLn0dh8\n"
"HKQgq/yAhq33bat+crbhmauBhy9mI+1iLiN0SXX2Jeo6gUuNsKwPIrbTFTYj2Uux\n"
"vXK8MvYz9jKVGfKY5ua28yWDBMkS45qAO2L1FV3eCFkb8EiZMSRZ8fqcxGD8dR3A\n"
"eyTbb6naguVXfe36qw+LVOnsQONkgmFi6aSIfudhAPfwo9Ekbp3P6Y5pWQB6/8U1\n"
"qUGcOvLa2YZ1DSQ4XbRfYf6xXL3dQ/MA1s9qErEBkqpukj1/13wjUKVX7VpPRCg0\n"
"eYSKZprocGQ2mrXjA+rb9kaWmWzTOqobMxxk5HtstxTG+I0PiwMO72Z2VESsqkGe\n"
"XXrk2tuR/3rGbIxMpUAS/d8sHKUHGERBpyeliGrin+QebNuU1ef6WUp1IXQMLg3x\n"
"3MNLvOhXAwEhPjtYFU2RHOTcmycxEadtT6KQIBQhkE2Vr5RF2C9C1vk3hBUlhWLA\n"
"ACkQWXvLNisjuMqp4RYhUVdWfZpQn8+PCXFkU6aPaO7QZa+u1DTF6WMCAwEAAQ==\n"
"-----END RSA PUBLIC KEY-----\n";

static string g_testPubkeyX509Str4096 = "-----BEGIN PUBLIC KEY-----\n"
"MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnDx8bd6se93OKCpW6F5v\n"
"i9eqAvmocX6X6wo7Rf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rcu48mWrSgamMccxz03fFQ9c6RMCqiD0EXA070i4hXUYm5cQCLMqb5VIzoczo\n"
"raTrnodf6Kl6pJvuYutmXwcRiXYJAc8WpwL+c15XkSUfedNMWucH9dcSlsL1JqmY\n"
"lM8cv+gJenr83Wko2bd3GR4/2sNGRKG6fRinJlUrtTp9X43G6nKcl346CblZYCQ6\n"
"qK4YA7u+Mn4+CRwiB82KlhLNXLVNxu9fs3yyBAlRQqDprka8egFTd9zU/b4QNjuU\n"
"bQIDAQAB\n"
"-----END PUBLIC KEY-----\n";

static string g_testPubkeyEccStr = "-----BEGIN PUBLIC KEY-----\n"
"MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEFZ5z0WC0cbwjdJjbHk6MlGTcVphvhNXf\n"
"Gi4r8wO9kpAMJZ8ql2r5Yzl9/L3U85FzuYRFEGQspCXvZf0fLSh4sg==\n"
"-----END PUBLIC KEY-----\n";

static string g_testPrikeyEccStr = "-----BEGIN EC PRIVATE KEY-----\n"
"MHQCAQEEIE0qd9kvmhww4glLxuEeF7NMgXz0YHj6sI8ibDBgU/iEoAcGBSuBBAAK\n"
"oUQDQgAEFZ5z0WC0cbwjdJjbHk6MlGTcVphvhNXfGi4r8wO9kpAMJZ8ql2r5Yzl9\n"
"/L3U85FzuYRFEGQspCXvZf0fLSh4sg==\n"
"-----END EC PRIVATE KEY-----\n";

static string g_encodedPrikeyRsaPkcs1Str = "-----BEGIN RSA PRIVATE KEY-----\n"
"Proc-Type: 4,ENCRYPTED\n"
"DEK-Info: AES-128-CBC,6E22B15C28BD9D5E33DBFEE4C643BF48\n\n"
"nUBkizR+GPCL5PgMIGGS/Lmp7w34ymnzvx67B6xAFmkN5+FZD71AFU0C3HyU0B8S\n"
"xJx/rmHjrcrKMRsXkurDCbh266+9qP55S+KhgtECqhkm+4flBzrbBjXrBOtFqpRO\n"
"dS1ApmLUx/ZUX/PNNHiAyKXNl7xBYh8AmSYZJzwFqWKs2RBV0nMURrF65mRgGSVr\n"
"il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NPIGIZWk7kvwZt3K\n"
"lS0aflPO6IdvDr1UxyBjJDyyuuzLBIfhwOjLPx+ohM6iW50CQQD/WABkLj2uW/5r\n"
"jQ14/nc1MRJrEu9BubbHdcGCVywDBvjTe4bWGU0/JJNBHpzD2jHCwkCkMN7l+Fll\n"
"CuIA8lLDAkEA81wi7eJqEIpb7T7RAA37tJW6J3TejNyaBlY8jdQPVf71BgDrw5aD\n"
"4beSifw8Za/ayNGdMBcncsyL+UCPNlajgwJBAOSIvtDrEgmcDHn2JLjGB6tz4Cg1\n"
"Ki6JKS4cFrWxj5KmCs49INE+lASPl7wQyf4Aq8jEU1ag5t6tCFWHCAAQ4kECQCm3\n"
"J32jjA7dyLg4Rlc+DmF8MPbGf8ehoP1pFuQw75gMJjArRD64tE6iywnAJRJBPL2j\n"
"wNAXh/mTuoK1YFcuLsUCQEUYsoNsTS1SqQpId1wYhUc4K8mF+kVcRzcYqPWPj4Y/\n"
"Y6GkLQIGQv3M7pDLfl5CCWrqRB1NdbuN3qaLiHO2OrI=\n"
"-----END RSA PRIVATE KEY-----\n";

static string g_PubkeyRsaPkcs1Str = "-----BEGIN RSA PUBLIC KEY-----\n"
"MIGJAoGBAPK8btYyQFDXF0cmHz4DskqLLE5OUTaHMTkIBhJrSiY9GZOyrWa4KpTs\n"
"v8SQJg4wl1cGu1xlgPBC5/x0e6RA7SWPORHI8UZgjm2hy6eAUslKvGuUSFtjO+xp\n"
"ztXVN0KRjxrbnI1PfXD7MJU4fKN7g40kZcE42/ADv+V54gq2NILJAgMBAAE=\n"
"-----END RSA PUBLIC KEY-----\n";

static void RsaAsyKeyPemTest1(const char *algoName, const char *priKeyPkcs1Str, const char *priKeyPkcs8Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, nullptr, priKeyPkcs1Str, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);
    HcfPriKey *prikey = dupKeyPair->priKey;
    char *retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, priKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs8Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

static void RsaAsyKeyPemTest2(const char *algoName, const char *priKeyPkcs8Str, const char *priKeyPkcs1Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, nullptr, priKeyPkcs8Str, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);
    HcfPriKey *prikey = dupKeyPair->priKey;
    char *retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, priKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs8Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

static void RsaAsyKeyPemTest3(const char *algoName, const char *pubKeyPkcs1Str, const char *pubKeyX509Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, pubKeyPkcs1Str, nullptr, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, pubKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, pubKeyX509Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

static void RsaAsyKeyPemTest4(const char *algoName, const char *pubKeyX509Str, const char *pubKeyPkcs1Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, pubKeyX509Str, nullptr, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, pubKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, pubKeyX509Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

static void RsaAsyKeyPemTest5(const char *algoName, const char *pubKeyPkcs1Str, const char *pubKeyX509Str,
    const char *priKeyPkcs1Str, const char *priKeyPkcs8Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, pubKeyPkcs1Str, priKeyPkcs1Str, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, pubKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, pubKeyX509Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    HcfPriKey *prikey = dupKeyPair->priKey;
    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs8Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

static void RsaAsyKeyPemTest6(const char *algoName, const char *pubKeyPkcs1Str, const char *pubKeyX509Str,
    const char *priKeyPkcs1Str, const char *priKeyPkcs8Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, pubKeyPkcs1Str, priKeyPkcs8Str, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, pubKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, pubKeyX509Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    HcfPriKey *prikey = dupKeyPair->priKey;
    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs8Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

static void RsaAsyKeyPemTest7(const char *algoName, const char *pubKeyPkcs1Str, const char *pubKeyX509Str,
    const char *priKeyPkcs1Str, const char *priKeyPkcs8Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, pubKeyX509Str, priKeyPkcs1Str, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, pubKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, pubKeyX509Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    HcfPriKey *prikey = dupKeyPair->priKey;
    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs8Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

static void RsaAsyKeyPemTest8(const char *algoName, const char *pubKeyPkcs1Str, const char *pubKeyX509Str,
    const char *priKeyPkcs1Str, const char *priKeyPkcs8Str)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate(algoName, &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, pubKeyX509Str, priKeyPkcs8Str, &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, pubKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, pubKeyX509Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    HcfPriKey *prikey = dupKeyPair->priKey;
    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs1Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, priKeyPkcs8Str);
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

// test pubkey is null, prikey is not null pkcs1 to pkcs8
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest001, TestSize.Level0)
{
    RsaAsyKeyPemTest1("RSA512", g_testPrikeyPkcs1Str512.c_str(), g_testPrikeyPkcs8Str512.c_str());
    RsaAsyKeyPemTest1("RSA768", g_testPrikeyPkcs1Str768.c_str(), g_testPrikeyPkcs8Str768.c_str());
    RsaAsyKeyPemTest1("RSA1024", g_testPrikeyPkcs1Str1024.c_str(), g_testPrikeyPkcs8Str1024.c_str());
    RsaAsyKeyPemTest1("RSA2048", g_testPrikeyPkcs1Str2048.c_str(), g_testPrikeyPkcs8Str2048.c_str());
    RsaAsyKeyPemTest1("RSA3072", g_testPrikeyPkcs1Str3072.c_str(), g_testPrikeyPkcs8Str3072.c_str());
    RsaAsyKeyPemTest1("RSA4096", g_testPrikeyPkcs1Str4096.c_str(), g_testPrikeyPkcs8Str4096.c_str());
    RsaAsyKeyPemTest1("RSA8192", g_testPrikeyPkcs1Str8192.c_str(), g_testPrikeyPkcs8Str8192.c_str());
}

// test pubkey is null, prikey is not null pkcs8 to pkcs1
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest002, TestSize.Level0)
{
    RsaAsyKeyPemTest2("RSA512", g_testPrikeyPkcs8Str512.c_str(), g_testPrikeyPkcs1Str512.c_str());
    RsaAsyKeyPemTest2("RSA768", g_testPrikeyPkcs8Str768.c_str(), g_testPrikeyPkcs1Str768.c_str());
    RsaAsyKeyPemTest2("RSA1024", g_testPrikeyPkcs8Str1024.c_str(), g_testPrikeyPkcs1Str1024.c_str());
    RsaAsyKeyPemTest2("RSA2048", g_testPrikeyPkcs8Str2048.c_str(), g_testPrikeyPkcs1Str2048.c_str());
    RsaAsyKeyPemTest2("RSA3072", g_testPrikeyPkcs8Str3072.c_str(), g_testPrikeyPkcs1Str3072.c_str());
    RsaAsyKeyPemTest2("RSA4096", g_testPrikeyPkcs8Str4096.c_str(), g_testPrikeyPkcs1Str4096.c_str());
    RsaAsyKeyPemTest2("RSA8192", g_testPrikeyPkcs8Str8192.c_str(), g_testPrikeyPkcs1Str8192.c_str());
}

// test pubkey is not null pkcs1 to x509, prikey is null
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest003, TestSize.Level0)
{
    RsaAsyKeyPemTest3("RSA512", g_testPubkeyPkcs1Str512.c_str(), g_testPubkeyX509Str512.c_str());
    RsaAsyKeyPemTest3("RSA768", g_testPubkeyPkcs1Str768.c_str(), g_testPubkeyX509Str768.c_str());
    RsaAsyKeyPemTest3("RSA1024", g_testPubkeyPkcs1Str1024.c_str(), g_testPubkeyX509Str1024.c_str());
    RsaAsyKeyPemTest3("RSA2048", g_testPubkeyPkcs1Str2048.c_str(), g_testPubkeyX509Str2048.c_str());
    RsaAsyKeyPemTest3("RSA3072", g_testPubkeyPkcs1Str3072.c_str(), g_testPubkeyX509Str3072.c_str());
    RsaAsyKeyPemTest3("RSA4096", g_testPubkeyPkcs1Str4096.c_str(), g_testPubkeyX509Str4096.c_str());
    RsaAsyKeyPemTest3("RSA8192", g_testPubkeyPkcs1Str8192.c_str(), g_testPubkeyX509Str8192.c_str());
}

// test pubkey is not null x509 to pkcs1, prikey is null
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest004, TestSize.Level0)
{
    RsaAsyKeyPemTest4("RSA512", g_testPubkeyX509Str512.c_str(), g_testPubkeyPkcs1Str512.c_str());
    RsaAsyKeyPemTest4("RSA768", g_testPubkeyX509Str768.c_str(), g_testPubkeyPkcs1Str768.c_str());
    RsaAsyKeyPemTest4("RSA1024", g_testPubkeyX509Str1024.c_str(), g_testPubkeyPkcs1Str1024.c_str());
    RsaAsyKeyPemTest4("RSA2048", g_testPubkeyX509Str2048.c_str(), g_testPubkeyPkcs1Str2048.c_str());
    RsaAsyKeyPemTest4("RSA3072", g_testPubkeyX509Str3072.c_str(), g_testPubkeyPkcs1Str3072.c_str());
    RsaAsyKeyPemTest4("RSA4096", g_testPubkeyX509Str4096.c_str(), g_testPubkeyPkcs1Str4096.c_str());
    RsaAsyKeyPemTest4("RSA8192", g_testPubkeyX509Str8192.c_str(), g_testPubkeyPkcs1Str8192.c_str());
}

// test pubkey is pkcs1 to x509, prikey is pkcs1 to pkcs8
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest005, TestSize.Level0)
{
    RsaAsyKeyPemTest5("RSA512", g_testPubkeyPkcs1Str512.c_str(), g_testPubkeyX509Str512.c_str(),
        g_testPrikeyPkcs1Str512.c_str(), g_testPrikeyPkcs8Str512.c_str());
    RsaAsyKeyPemTest5("RSA768", g_testPubkeyPkcs1Str768.c_str(), g_testPubkeyX509Str768.c_str(),
        g_testPrikeyPkcs1Str768.c_str(), g_testPrikeyPkcs8Str768.c_str());
    RsaAsyKeyPemTest5("RSA1024", g_testPubkeyPkcs1Str1024.c_str(), g_testPubkeyX509Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), g_testPrikeyPkcs8Str1024.c_str());
    RsaAsyKeyPemTest5("RSA2048", g_testPubkeyPkcs1Str2048.c_str(), g_testPubkeyX509Str2048.c_str(),
        g_testPrikeyPkcs1Str2048.c_str(), g_testPrikeyPkcs8Str2048.c_str());
    RsaAsyKeyPemTest5("RSA3072", g_testPubkeyPkcs1Str3072.c_str(), g_testPubkeyX509Str3072.c_str(),
        g_testPrikeyPkcs1Str3072.c_str(), g_testPrikeyPkcs8Str3072.c_str());
    RsaAsyKeyPemTest5("RSA4096", g_testPubkeyPkcs1Str4096.c_str(), g_testPubkeyX509Str4096.c_str(),
        g_testPrikeyPkcs1Str4096.c_str(), g_testPrikeyPkcs8Str4096.c_str());
    RsaAsyKeyPemTest5("RSA8192", g_testPubkeyPkcs1Str8192.c_str(), g_testPubkeyX509Str8192.c_str(),
        g_testPrikeyPkcs1Str8192.c_str(), g_testPrikeyPkcs8Str8192.c_str());
}

// test pubkey is pkcs1 to x509, prikey is pkcs8 to pkcs1
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest006, TestSize.Level0)
{
    RsaAsyKeyPemTest6("RSA512", g_testPubkeyPkcs1Str512.c_str(), g_testPubkeyX509Str512.c_str(),
        g_testPrikeyPkcs1Str512.c_str(), g_testPrikeyPkcs8Str512.c_str());
    RsaAsyKeyPemTest6("RSA768", g_testPubkeyPkcs1Str768.c_str(), g_testPubkeyX509Str768.c_str(),
        g_testPrikeyPkcs1Str768.c_str(), g_testPrikeyPkcs8Str768.c_str());
    RsaAsyKeyPemTest6("RSA1024", g_testPubkeyPkcs1Str1024.c_str(), g_testPubkeyX509Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), g_testPrikeyPkcs8Str1024.c_str());
    RsaAsyKeyPemTest6("RSA2048", g_testPubkeyPkcs1Str2048.c_str(), g_testPubkeyX509Str2048.c_str(),
        g_testPrikeyPkcs1Str2048.c_str(), g_testPrikeyPkcs8Str2048.c_str());
    RsaAsyKeyPemTest6("RSA3072", g_testPubkeyPkcs1Str3072.c_str(), g_testPubkeyX509Str3072.c_str(),
        g_testPrikeyPkcs1Str3072.c_str(), g_testPrikeyPkcs8Str3072.c_str());
    RsaAsyKeyPemTest6("RSA4096", g_testPubkeyPkcs1Str4096.c_str(), g_testPubkeyX509Str4096.c_str(),
        g_testPrikeyPkcs1Str4096.c_str(), g_testPrikeyPkcs8Str4096.c_str());
    RsaAsyKeyPemTest6("RSA8192", g_testPubkeyPkcs1Str8192.c_str(), g_testPubkeyX509Str8192.c_str(),
        g_testPrikeyPkcs1Str8192.c_str(), g_testPrikeyPkcs8Str8192.c_str());
}

// test pubkey is x509 to pkcs1, prikey is pkcs1 to pkcs8
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest007, TestSize.Level0)
{
    RsaAsyKeyPemTest7("RSA512", g_testPubkeyPkcs1Str512.c_str(), g_testPubkeyX509Str512.c_str(),
        g_testPrikeyPkcs1Str512.c_str(), g_testPrikeyPkcs8Str512.c_str());
    RsaAsyKeyPemTest7("RSA768", g_testPubkeyPkcs1Str768.c_str(), g_testPubkeyX509Str768.c_str(),
        g_testPrikeyPkcs1Str768.c_str(), g_testPrikeyPkcs8Str768.c_str());
    RsaAsyKeyPemTest7("RSA1024", g_testPubkeyPkcs1Str1024.c_str(), g_testPubkeyX509Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), g_testPrikeyPkcs8Str1024.c_str());
    RsaAsyKeyPemTest7("RSA2048", g_testPubkeyPkcs1Str2048.c_str(), g_testPubkeyX509Str2048.c_str(),
        g_testPrikeyPkcs1Str2048.c_str(), g_testPrikeyPkcs8Str2048.c_str());
    RsaAsyKeyPemTest7("RSA3072", g_testPubkeyPkcs1Str3072.c_str(), g_testPubkeyX509Str3072.c_str(),
        g_testPrikeyPkcs1Str3072.c_str(), g_testPrikeyPkcs8Str3072.c_str());
    RsaAsyKeyPemTest7("RSA4096", g_testPubkeyPkcs1Str4096.c_str(), g_testPubkeyX509Str4096.c_str(),
        g_testPrikeyPkcs1Str4096.c_str(), g_testPrikeyPkcs8Str4096.c_str());
    RsaAsyKeyPemTest7("RSA8192", g_testPubkeyPkcs1Str8192.c_str(), g_testPubkeyX509Str8192.c_str(),
        g_testPrikeyPkcs1Str8192.c_str(), g_testPrikeyPkcs8Str8192.c_str());
}

// test pubkey is x509 to pkcs1, prikey is pkcs8 to pkcs1
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemTest008, TestSize.Level0)
{
    RsaAsyKeyPemTest8("RSA512", g_testPubkeyPkcs1Str512.c_str(), g_testPubkeyX509Str512.c_str(),
        g_testPrikeyPkcs1Str512.c_str(), g_testPrikeyPkcs8Str512.c_str());
    RsaAsyKeyPemTest8("RSA768", g_testPubkeyPkcs1Str768.c_str(), g_testPubkeyX509Str768.c_str(),
        g_testPrikeyPkcs1Str768.c_str(), g_testPrikeyPkcs8Str768.c_str());
    RsaAsyKeyPemTest8("RSA1024", g_testPubkeyPkcs1Str1024.c_str(), g_testPubkeyX509Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), g_testPrikeyPkcs8Str1024.c_str());
    RsaAsyKeyPemTest8("RSA2048", g_testPubkeyPkcs1Str2048.c_str(), g_testPubkeyX509Str2048.c_str(),
        g_testPrikeyPkcs1Str2048.c_str(), g_testPrikeyPkcs8Str2048.c_str());
    RsaAsyKeyPemTest8("RSA3072", g_testPubkeyPkcs1Str3072.c_str(), g_testPubkeyX509Str3072.c_str(),
        g_testPrikeyPkcs1Str3072.c_str(), g_testPrikeyPkcs8Str3072.c_str());
    RsaAsyKeyPemTest8("RSA4096", g_testPubkeyPkcs1Str4096.c_str(), g_testPubkeyX509Str4096.c_str(),
        g_testPrikeyPkcs1Str4096.c_str(), g_testPrikeyPkcs8Str4096.c_str());
    RsaAsyKeyPemTest8("RSA8192", g_testPubkeyPkcs1Str8192.c_str(), g_testPubkeyX509Str8192.c_str(),
        g_testPrikeyPkcs1Str8192.c_str(), g_testPrikeyPkcs8Str8192.c_str());
}

// test ConvertPemKey parma is null
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest001, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, nullptr, nullptr, &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    res = generator->convertPemKey(nullptr, nullptr, g_testPubkeyX509Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    res = generator->convertPemKey(generator, nullptr, g_testPubkeyX509Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), nullptr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);
    HcfObjDestroy(generator);
}

// test ConvertPemKey pubkey and prikey is invalid
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest002, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, "pubkey", g_testPrikeyPkcs1Str1024.c_str(), &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    res = generator->convertPemKey(generator, nullptr, g_testPubkeyX509Str1024.c_str(), "prikey", &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    res = generator->convertPemKey(generator, nullptr, "pubkey", "prikey", &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    HcfObjDestroy(generator);
}

// test getEncodedPem param is null
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest003, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, g_testPubkeyPkcs1Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem(nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    pubkey = dupKeyPair->pubKey;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, nullptr, &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    pubkey = dupKeyPair->pubKey;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", nullptr);
    EXPECT_NE(res, HCF_SUCCESS);

    HcfPriKey *prikey = dupKeyPair->priKey;
    res = prikey->getEncodedPem(nullptr, nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    prikey = dupKeyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, nullptr, &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    prikey = dupKeyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", nullptr);
    EXPECT_NE(res, HCF_SUCCESS);

    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

// test getEncodedPem param is invalid
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest004, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, g_testPubkeyPkcs1Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), &dupKeyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = dupKeyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    pubkey = dupKeyPair->pubKey;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "test", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    pubkey = dupKeyPair->pubKey;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "pkcs1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    pubkey = dupKeyPair->pubKey;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "x509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    HcfPriKey *prikey = dupKeyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "X509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    prikey = dupKeyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "test", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    prikey = dupKeyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "pkcs1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    prikey = dupKeyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "pkcs8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);

    HcfObjDestroy(dupKeyPair);
    HcfObjDestroy(generator);
}

//test convertPemKey ecc pubkey and prikey
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest005, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, g_testPubkeyEccStr.c_str(), g_testPrikeyEccStr.c_str(),
        &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    res = generator->convertPemKey(generator, nullptr, g_testPubkeyEccStr.c_str(), nullptr, &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    res = generator->convertPemKey(generator, nullptr, nullptr, g_testPrikeyEccStr.c_str(), &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    HcfObjDestroy(generator);
}

// test getEncodedPem ecc pubkey and ecc prikey
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest006, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    int32_t res = HcfAsyKeyGeneratorCreate("ECC224", &generator);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(keyPair, nullptr);
    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

// test getEncodedPem dsa pubkey and prikey
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest007, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    int32_t res = HcfAsyKeyGeneratorCreate("DSA1024", &generator);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(keyPair, nullptr);
    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

// test getEncodedPem sm2 pubkey and prikey
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest008, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    int32_t res = HcfAsyKeyGeneratorCreate("SM2_256", &generator);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(keyPair, nullptr);
    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

// test getEncodedPem Ed25519 pubkey and prikey
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest009, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    int32_t res = HcfAsyKeyGeneratorCreate("Ed25519", &generator);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(keyPair, nullptr);
    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

// test getEncodedPem X25519 pubkey and prikey
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest010, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    int32_t res = HcfAsyKeyGeneratorCreate("X25519", &generator);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(keyPair, nullptr);
    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

// test getEncodedPem dh pubkey and prikey
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemErrorTest011, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    int32_t res = HcfAsyKeyGeneratorCreate("DH_modp1536", &generator);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(keyPair, nullptr);
    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(retStr, nullptr);

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

// test engineConvertPemKey Pubkey and Prikey 2048
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemSpiTest001, TestSize.Level0)
{
    HcfAsyKeyGeneratorSpi *spiObj = nullptr;
    HcfAsyKeyGenParams params = {
        .algo = HCF_ALG_RSA,
        .bits = OPENSSL_RSA_KEY_SIZE_2048,
        .primes = 0,
    };

    HcfResult res = HcfAsyKeyGeneratorSpiRsaCreate(&params, &spiObj);

    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(spiObj, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = spiObj->engineConvertPemKey(spiObj, nullptr, g_testPubkeyPkcs1Str2048.c_str(),
        g_testPrikeyPkcs1Str2048.c_str(), &keyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, g_testPubkeyPkcs1Str2048.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, g_testPubkeyX509Str2048.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    HcfPriKey *prikey = keyPair->priKey;
    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, g_testPrikeyPkcs1Str2048.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, g_testPrikeyPkcs8Str2048.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(keyPair);
    HcfObjDestroy(spiObj);
}

// test engineConvertPemKey Pubkey and Prikey 1024
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemSpiTest002, TestSize.Level0)
{
    HcfAsyKeyGeneratorSpi *spiObj = nullptr;
    HcfAsyKeyGenParams params = {
        .algo = HCF_ALG_RSA,
        .bits = OPENSSL_RSA_KEY_SIZE_1024,
        .primes = 0,
    };

    HcfResult res = HcfAsyKeyGeneratorSpiRsaCreate(&params, &spiObj);

    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(spiObj, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = spiObj->engineConvertPemKey(spiObj, nullptr, g_testPubkeyPkcs1Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), &keyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfPubKey *pubkey = keyPair->pubKey;
    char *retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    int32_t cmpRes = strcmp(retStr, g_testPubkeyPkcs1Str1024.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    retStr = nullptr;
    res = pubkey->base.getEncodedPem((HcfKey *)pubkey, "X509", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, g_testPubkeyX509Str1024.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    HcfPriKey *prikey = keyPair->priKey;
    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, g_testPrikeyPkcs1Str1024.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    HcfFree(retStr);

    retStr = nullptr;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);
    cmpRes = strcmp(retStr, g_testPrikeyPkcs8Str1024.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);

    HcfFree(retStr);
    HcfObjDestroy(keyPair);
    HcfObjDestroy(spiObj);
}

// test engineConvertPemKey param is invalid
HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyPemSpiErrorTest001, TestSize.Level0)
{
    HcfAsyKeyGeneratorSpi *spiObj = nullptr;
    HcfAsyKeyGenParams params = {
        .algo = HCF_ALG_RSA,
        .bits = OPENSSL_RSA_KEY_SIZE_1024,
        .primes = 0,
    };

    HcfResult res = HcfAsyKeyGeneratorSpiRsaCreate(&params, &spiObj);

    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(spiObj, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = spiObj->engineConvertPemKey(nullptr, nullptr, g_testPubkeyPkcs1Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), &keyPair);
    EXPECT_NE(res, HCF_SUCCESS);

    res = spiObj->engineConvertPemKey(spiObj, nullptr, nullptr, nullptr, &keyPair);
    EXPECT_NE(res, HCF_SUCCESS);

    res = spiObj->engineConvertPemKey(spiObj, nullptr, g_testPubkeyPkcs1Str1024.c_str(),
        g_testPrikeyPkcs1Str1024.c_str(), nullptr);
    EXPECT_NE(res, HCF_SUCCESS);

    HcfKeyDecodingParamsSpec spec = {};
    spec.password = (char *)"";
    res = spiObj->engineConvertPemKey(spiObj, reinterpret_cast<HcfParamsSpec *>(&spec), "", "", &keyPair);
    EXPECT_EQ(res, HCF_INVALID_PARAMS);

    HcfObjDestroy(spiObj);
}

HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeySpecApiTest, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    int32_t res = HcfAsyKeyGeneratorCreate("Ed25519", &generator);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    ASSERT_EQ(res, HCF_SUCCESS);
    ASSERT_NE(keyPair, nullptr);

    HcfPriKey *prikey = keyPair->priKey;
    char *retStr = nullptr;
    res = prikey->getAsyKeySpecString(prikey, RSA_N_BN, &retStr);
    ASSERT_EQ(res, HCF_NOT_SUPPORT);
    ASSERT_EQ(retStr, nullptr);

    int32_t returnInt = 0;
    res = prikey->getAsyKeySpecInt(prikey, RSA_N_BN, &returnInt);
    ASSERT_EQ(res, HCF_NOT_SUPPORT);
    ASSERT_EQ(returnInt, 0);

    HcfBigInteger retBigInt = { .data = NULL, .len = 0 };
    res = prikey->getAsyKeySpecBigInteger(prikey, RSA_N_BN, &retBigInt);
    ASSERT_EQ(res, HCF_INVALID_PARAMS);
    ASSERT_EQ(retBigInt.data, nullptr);
    ASSERT_EQ(retBigInt.len, 0);
    HcfFree(retBigInt.data);

    HcfBlob priKeyBlob = { .data = nullptr, .len = 0 };
    res = prikey->getEncodedDer(keyPair->priKey, "PKCS1", &priKeyBlob);
    ASSERT_EQ(res, HCF_INVALID_PARAMS);
    ASSERT_EQ(priKeyBlob.data, nullptr);
    ASSERT_EQ(priKeyBlob.len, 0);

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
    HcfFree(priKeyBlob.data);
}

static void FreeEncodeParamsSpec(HcfKeyEncodingParamsSpec *spec)
{
    if (spec == nullptr) {
        return;
    }
    if (spec->password != nullptr) {
        size_t pwdLen = strlen(spec->password);
        (void)memset_s((void*)spec->password, pwdLen, 0, pwdLen);
        HcfFree(static_cast<void *>(spec->password));
        spec->password = nullptr;
    }
    if (spec->cipher != nullptr) {
        HcfFree(static_cast<void *>(spec->cipher));
        spec->cipher = nullptr;
    }
    HcfFree(spec);
    spec = nullptr;
}

static void FreeDecodeParamsSpec(HcfKeyDecodingParamsSpec *spec)
{
    if (spec == nullptr) {
        return;
    }
    if (spec->password != nullptr) {
        size_t pwdLen = strlen(spec->password);
        (void)memset_s((void*)spec->password, pwdLen, 0, pwdLen);
        HcfFree(static_cast<void *>(spec->password));
        spec->password = nullptr;
    }
    HcfFree(spec);
    spec = nullptr;
}

HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyDecodeTest, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyDecodingParamsSpec *decSpec = (HcfKeyDecodingParamsSpec *)HcfMalloc(sizeof(HcfKeyDecodingParamsSpec), 0);
    ASSERT_NE(decSpec, nullptr);
    decSpec->password = (char *)HcfMalloc(strlen("123456") + 1, 0);
    ASSERT_NE(decSpec->password, nullptr);
    (void)memcpy_s((void *)decSpec->password, strlen("123456") + 1, "123456", strlen("123456") + 1);

    HcfParamsSpec *decParams = reinterpret_cast<HcfParamsSpec *>(decSpec);
    HcfKeyPair *keyPair = nullptr;
    res = generator->convertPemKey(generator, decParams, nullptr, g_encodedPrikeyRsaPkcs1Str.c_str(), &keyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    char *retStr = nullptr;
    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem(prikey, nullptr, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);

    int32_t cmpRes = strcmp(retStr, g_PrikeyRsaPkcs1Str.c_str());
    EXPECT_EQ(cmpRes, HCF_SUCCESS);
    FreeDecodeParamsSpec(decSpec);

    HcfFree(retStr);
    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyEncodeTest, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->convertPemKey(generator, nullptr, g_PubkeyRsaPkcs1Str.c_str(),
        g_PrikeyRsaPkcs1Str.c_str(), &keyPair);
    EXPECT_EQ(res, HCF_SUCCESS);
    HcfKeyEncodingParamsSpec *spec = (HcfKeyEncodingParamsSpec *)HcfMalloc(sizeof(HcfKeyEncodingParamsSpec), 0);
    ASSERT_NE(spec, nullptr);

    char *retStr = nullptr;
    HcfPriKey *prikey = keyPair->priKey;
    spec->password = (char *)"";
    spec->cipher = (char *)HcfMalloc(strlen("AES-128-CBC") + 1, 0);
    ASSERT_NE(spec->cipher, nullptr);
    (void)memcpy_s((void *)spec->cipher, strlen("AES-128-CBC") + 1, "AES-128-CBC", strlen("AES-128-CBC") + 1);

    HcfParamsSpec *params = reinterpret_cast<HcfParamsSpec *>(spec);
    res = prikey->getEncodedPem(prikey, params, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_INVALID_PARAMS);

    spec->password = (char *)HcfMalloc(strlen("123456") + 1, 0);
    ASSERT_NE(spec->password, nullptr);
    (void)memcpy_s((void *)spec->password, strlen("123456") + 1, "123456", strlen("123456") + 1);

    res = prikey->getEncodedPem(prikey, params, "PKCS1", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);

    int32_t cmpRes = strcmp(retStr, g_encodedPrikeyRsaPkcs1Str.c_str());
    EXPECT_NE(cmpRes, HCF_SUCCESS);
    FreeEncodeParamsSpec(spec);

    HcfFree(retStr);
    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyEncodeTest_DifferentCiphers, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    const char* ciphers[] = {"AES-256-CBC", "DES-EDE3-CBC", "AES-192-CBC"};
    const char* passwords[] = {"test123", "password123!", "strongPW@999"};

    for (int i = 0; i < 3; i++) {
        HcfKeyEncodingParamsSpec *spec = (HcfKeyEncodingParamsSpec *)HcfMalloc(sizeof(HcfKeyEncodingParamsSpec), 0);
        ASSERT_NE(spec, nullptr);

        spec->password = (char *)HcfMalloc(strlen(passwords[i]) + 1, 0);
        ASSERT_NE(spec->password, nullptr);
        (void)memcpy_s((void *)spec->password, strlen(passwords[i]) + 1,
            passwords[i], strlen(passwords[i]) + 1);

        spec->cipher = (char *)HcfMalloc(strlen(ciphers[i]) + 1, 0);
        ASSERT_NE(spec->cipher, nullptr);
        (void)memcpy_s((void *)spec->cipher, strlen(ciphers[i]) + 1, ciphers[i], strlen(ciphers[i]) + 1);

        HcfParamsSpec *params = reinterpret_cast<HcfParamsSpec *>(spec);

        char *retStr = nullptr;
        HcfPriKey *prikey = keyPair->priKey;
        res = prikey->getEncodedPem((const HcfPriKey *)prikey, params, "PKCS8", &retStr);
        EXPECT_EQ(res, HCF_SUCCESS);

        HcfKeyDecodingParamsSpec *decSpec = (HcfKeyDecodingParamsSpec *)HcfMalloc(sizeof(HcfKeyDecodingParamsSpec), 0);
        ASSERT_NE(decSpec, nullptr);
        decSpec->password = (char *)HcfMalloc(strlen(passwords[i]) + 1, 0);
        ASSERT_NE(decSpec->password, nullptr);
        (void)memcpy_s((void *)decSpec->password, strlen(passwords[i]) + 1,
            passwords[i], strlen(passwords[i]) + 1);

        HcfParamsSpec *decParams = reinterpret_cast<HcfParamsSpec *>(decSpec);
        HcfKeyPair *dupKeyPair = nullptr;
        res = generator->convertPemKey(generator, decParams, nullptr, retStr, &dupKeyPair);
        EXPECT_EQ(res, HCF_SUCCESS);

        FreeEncodeParamsSpec(spec);
        FreeDecodeParamsSpec(decSpec);
        HcfFree(retStr);
        HcfObjDestroy(dupKeyPair);
    }

    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}

HWTEST_F(CryptoRsaAsyKeyPemTest, CryptoRsaAsyKeyEncodeTest_WrongPassword, TestSize.Level0)
{
    HcfAsyKeyGenerator *generator = nullptr;
    HcfResult res = HcfAsyKeyGeneratorCreate("RSA1024", &generator);
    EXPECT_EQ(res, HCF_SUCCESS);
    EXPECT_NE(generator, nullptr);

    HcfKeyPair *keyPair = nullptr;
    res = generator->generateKeyPair(generator, nullptr, &keyPair);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfKeyEncodingParamsSpec *spec = (HcfKeyEncodingParamsSpec *)HcfMalloc(sizeof(HcfKeyEncodingParamsSpec), 0);
    ASSERT_NE(spec, nullptr);
    spec->password = (char *)HcfMalloc(strlen("correctPW") + 1, 0);
    ASSERT_NE(spec->password, nullptr);
    (void)memcpy_s((void *)spec->password, strlen("correctPW") + 1,
        "correctPW", strlen("correctPW") + 1);

    spec->cipher = (char *)HcfMalloc(strlen("AES-128-CBC") + 1, 0);
    ASSERT_NE(spec->cipher, nullptr);
    (void)memcpy_s((void *)spec->cipher, strlen("AES-128-CBC") + 1,
        "AES-128-CBC", strlen("AES-128-CBC") + 1);

    HcfParamsSpec *params = reinterpret_cast<HcfParamsSpec *>(spec);

    char *retStr = nullptr;
    HcfPriKey *prikey = keyPair->priKey;
    res = prikey->getEncodedPem((const HcfPriKey *)prikey, params, "PKCS8", &retStr);
    EXPECT_EQ(res, HCF_SUCCESS);

    HcfKeyDecodingParamsSpec *decSpec = (HcfKeyDecodingParamsSpec *)HcfMalloc(sizeof(HcfKeyDecodingParamsSpec), 0);
    ASSERT_NE(decSpec, nullptr);
    decSpec->password = (char *)HcfMalloc(strlen("wrongPW") + 1, 0);
    ASSERT_NE(decSpec->password, nullptr);
    (void)memcpy_s((void *)decSpec->password, strlen("wrongPW") + 1, "wrongPW", strlen("wrongPW") + 1);

    HcfParamsSpec *decParams = reinterpret_cast<HcfParamsSpec *>(decSpec);
    HcfKeyPair *dupKeyPair = nullptr;
    res = generator->convertPemKey(generator, decParams, nullptr, retStr, &dupKeyPair);
    EXPECT_NE(res, HCF_SUCCESS);
    EXPECT_EQ(dupKeyPair, nullptr);

    FreeEncodeParamsSpec(spec);
    FreeDecodeParamsSpec(decSpec);
    HcfFree(retStr);
    HcfObjDestroy(keyPair);
    HcfObjDestroy(generator);
}
}
